package qldc.pm.tienan.constants;

import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.Validator;

import qldc.pm.tienan.dto.LichSuXoaAnTichDTO;
import qldc.pm.tienan.model.LichSuXoaAnTich;
import qldc.pm.tienan.model.PhieuThongTinVeNguoiCoTienAn;
import qldc.pm.tienan.model.TienAn;
import qldc.pm.tienan.service.PhieuThongTinVeNguoiCoTienAnLocalServiceUtil;
import qldc.pm.tienan.service.TienAnLocalServiceUtil;

public class PrintConverter {

	public static LichSuXoaAnTichDTO convertLichSuXoaAnTichToDto(
			LichSuXoaAnTich ls) throws SystemException {
		LichSuXoaAnTichDTO dto = new LichSuXoaAnTichDTO();
		TienAn ts = TienAnLocalServiceUtil.fetchTienAn(ls.getTienAnId());
		PhieuThongTinVeNguoiCoTienAn phieu = PhieuThongTinVeNguoiCoTienAnLocalServiceUtil.findByTienAnId(ts.getTienAnId());
		dto.setBanAnSo(ts.getBanAnSo());
		dto.setCoQuanThiHanhAn(ls.getCoQuanThiHanhAn());
		dto.setDiaChi(Validator.isNull(phieu.getNoiThuongTruDiaChi()) ? phieu.getNoiTamTruDiaChi() : phieu.getNoiThuongTruDiaChi());
		dto.setHinhPhat(ls.getHinhPhat());
		dto.setHoVaTenDoiTuongTienAn(ls.getHoVaTenDoiTuongTienAn());
		dto.setKinhGui(ls.getKinhGui());
		dto.setLichSuXoaAnTichId(ls.getLichSuXoaAnTichId());
		dto.setMaHoSoXoaAnTich(ls.getMaHoSoXoaAnTich());
		dto.setNgayKyDuyetXoaAnTich(ls.getNgayKyDuyetXoaAnTich());
		dto.setNgayQuyetDinhThiHanhAn(ls.getNgayQuyetDinhThiHanhAn());
		dto.setNgayToaAn(ts.getNgayToaAn());
		dto.setNgayYeuCauXoaAnTich(ls.getNgayYeuCauXoaAnTich());
		dto.setNguoiThucHienXoaAnTichTrongDuLieuID(ls.getNguoiThucHienXoaAnTichTrongDuLieuID());
		dto.setNguoiLapHoSoXoaAnTichId(ls.getNguoiLapHoSoXoaAnTichId());
		dto.setNguoiYeuCauXoaAnTich(ls.getNguoiYeuCauXoaAnTich());
		dto.setSoQuyetDinhThiHanhAn(ls.getSoQuyetDinhThiHanhAn());
		dto.setTienAnId(ts.getTienAnId());
		dto.setToaAn(ts.getToaAnXuPhat());
		return dto;
	}

}
